﻿using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Dryricenet
{
    public partial class ph_Collect : System.Web.UI.Page
    {
        private int id = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            string name = Session["Name"].ToString();
            DataTable dt = userBLL.selectNameBll(name);
            DataRow dr = dt.Rows[0];//第一条数据
            id = Convert.ToInt32(dr["UserID"]);
            if (!IsPostBack)
            {
               
                Refresh(id);
                
            }
        }
        //刷新
        public void Refresh(int id)
        {
            GridView1.DataSource = CollectionBLL.phSCIDBLL(id);
            GridView1.DataBind();
        }
        //取消收藏
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32((sender as LinkButton).CssClass);
            if (CollectionBLL.qhQXBLL(id))
            {
                Refresh(id);
                Response.Write("<script>alert('取消收藏成功！');history.back();</script>");
                Response.End();
            }
            else {
                Response.Write("<script>alert('取消收藏失败！');history.back();</script>");
                Response.End();
            }
            
        }
        //分页
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            Refresh(id);
        }
    }
}